#include "ProxyDialog.h"
#include "ui_ProxyDialog.h"

#include "ConnectionSettings.h"

ProxyDialog::ProxyDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ProxyDialog)
{
    ui->setupUi(this);

    QRegExp rx("\\d+");
    QRegExpValidator *validator = new QRegExpValidator(rx, this);
    ui->port_lineEdit->setValidator(validator);
}

ProxyDialog::~ProxyDialog()
{
    delete ui;
}

ConnectionSettings ProxyDialog::value()
{
    ConnectionSettings settings;
    settings.useProxy = ui->proxy_groupBox->isChecked();
    settings.proxy_addres = ui->address_lineEdit->text();
    settings.proxy_port = ui->port_lineEdit->text().toInt();

    settings.user = ui->user_lineEdit->text();
    settings.pass = ui->pass_lineEdit->text();

    return settings;
}
